package it.polimi.authentication.web.beans;


import it.polimi.TravelDream.BaseProductMgr;
import it.polimi.TravelDream.ExcursionDTO;
import it.polimi.TravelDream.FlightDTO;
import it.polimi.TravelDream.HotelDTO;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name="insertionBean")
@RequestScoped
public class InsertionBean {

	
	@EJB
	private BaseProductMgr baseProductMgr;

	private FlightDTO flight;
	private HotelDTO hotel;
	private ExcursionDTO excursion;

	public InsertionBean() {
		flight = new FlightDTO();
		hotel = new HotelDTO();
		excursion = new ExcursionDTO();
	}

	public FlightDTO getFlight() {
		return flight;
	}

	public void setFlight(FlightDTO flight) {
		this.flight = flight;
	}
	
	public String insertFlight() {
		baseProductMgr.saveFlight(flight);
		return "/admins/home?faces-redirect=true";
	}
	
	public HotelDTO getHotel() {
		return hotel;
	}

	public void setHotel(HotelDTO hotel) {
		this.hotel = hotel;
	}
	
	public String insertHotel() {
		baseProductMgr.saveHotel(hotel);
		return "/admins/home?faces-redirect=true";
	}
	
	public ExcursionDTO getExcursion() {
		return excursion;
	}

	public void setExcursion(ExcursionDTO excursion) {
		this.excursion = excursion;
	}
	
	public String insertExcursion() {
		baseProductMgr.saveExcursion(excursion);
		return "/admins/home?faces-redirect=true";
	}
}
